<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/10
 * Time: 13:34
 */
class MymessagesApp extends CommonApp {

    //我的消息
    public function messageAct(){
        $result = $this->checkLogin();
        $search['where'] = "parent_id={$result['memberid']}";
        $search['page'] = My::arr2var($_REQUEST,'page').(isset($_SESSION['pagesize'])?$_SESSION['pagesize']:'');//用于参与缓存标识
        //缓存时间
        $search['time'] = isset($_COOKIE['time']) ? $_COOKIE['time'] : strtotime(date("Y-m-d H:i:s"));
        //缓存时间
        $message = My::getCache($search,array('pre'=>'message'));
        if($message == ''){
            $total = DB('message2')->where($search['where'])->cache()->count();
            $message['page'] = My::page($total,array('pagesize'=>3,'buttonNum'=>3,'prev'=>'<','next'=>'>','first'=>'<<','last'=>'>>'));
            //数据
            $message['data'] = DB('message2')->where($search['where'])->limit($message['page']['limits'])->order('adddate DESC,id DESC')->cache()->select();
            foreach($message['data'] as &$value){
                $value['content'] = My::decodeJson($value['content']);
            }
            My::setCache($search,$message,array('pre'=>'message'));
//            echo '没有消息缓存，刷新下';
//            exit();
        }
        $this->assign('result',$result);
        $this->assign('message',$message);
        $this->display();
    }
}